
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0796
 * @Author : WangRuoyu 
 * @Date : 2023/9/13 20:19
 */

#include "iostream"

using namespace std;

int main() {
    int m, n, k;
    scanf("%d %d %d", &m, &n, &k);
    int a[m + 1][n + 1];
    int s[m + 1][n + 1];

    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i == 0 || j == 0) {
                a[i][j] = 0;
                s[i][j] = 0;
            } else {
                scanf("%d", &a[i][j]);
                s[i][j] = a[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
            }
        }
    }

    while (k--) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        printf("%d\n", s[x2][y2] + s[x1 - 1][y1 - 1] - s[x2][y1 - 1] - s[x1 - 1][y2]);
    }

    return 0;
}